const {domain, acid, version_number} = require('./config');
var app = getApp();

/**
 * 订单列表-新订单
 */
export function cleaninglist(params, success, fail = null) {
    uni.request({
        url: domain + '/index.php?s=/shared/user.cleaning/list',
        method: 'POST',
        data: {
            ...params,
            access_token: app.globalData.access_token,
            _acid: acid
        },
        success: success,
        fail: fail
    });
}

/**
 * 抢单
 */
export function cleaninghandle(params, success, fail = null) {
    uni.request({
        url: domain + '/index.php?s=/shared/user.cleaning/handle',
        method: 'POST',
        data: {
            ...params,
            access_token: app.globalData.access_token,
            _acid: acid
        },
        success: success,
        fail: fail
    });
}

/**
 * 保洁开大门
 */
export function cleancontrollerOpenDoor(params, success, fail = null) {
    uni.request({
        url: domain + '/index.php?s=/shared/user.cleaning/controllerOpenDoor',
        method: 'POST',
        data: {
            ...params,
            access_token: app.globalData.access_token,
            _acid: acid
        },
        success: success,
        fail: fail
    });
}

/**
 * 保洁开灯
 */
export function cleancontrollerElectricity(params, success, fail = null) {
    uni.request({
        url: domain + '/index.php?s=/shared/user.cleaning/controllerElectricity',
        method: 'POST',
        data: {
            ...params,
            access_token: app.globalData.access_token,
            _acid: acid
        },
        success: success,
        fail: fail
    });
}
/**
 * 保洁完成订单
 */
export function overcontrollerElectricity(params, success, fail = null) {
    uni.request({
        url: domain + '/index.php?s=/shared/user.cleaning/controllerElectricity',
        method: 'POST',
        data: {
            ...params,
            access_token: app.globalData.access_token,
            _acid: acid
        },
        success: success,
        fail: fail
    });
}
/**
 * 保洁统计
 */
export function cleaningstatistics(params, success, fail = null) {
    uni.request({
        url: domain + '/index.php?s=/shared/user.cleaning/statistics',
        method: 'POST',
        data: {
            ...params,
            access_token: app.globalData.access_token,
            _acid: acid
        },
        success: success,
        fail: fail
    });
}

/**
 * 开大门
 */
export function houseorderopenDoor(params, success, fail = null) {
    uni.request({
        url: domain + '/index.php?s=/shared/user.house_order/openDoor',
        method: 'POST',
        data: {
            ...params,
            access_token: app.globalData.access_token,
            _acid: acid
        },
        success: success,
        fail: fail
    });
}


/**
 * 微信登录-第一步
 */
export function userlogin(success, fail = null) {
    uni.login({
        success: (res) => {
            if (res.code) {
                uni.request({
                    method: 'POST',
                    url: domain + '/index.php?s=/shared/user.login/getWxapp',
                    data: {
                        code: res.code,
                        weixin_login_status: 1,
                        _acid: acid
                    },
                    success: (getWxappres) => {
                        success(getWxappres, res.code);
                    },
                    fail: fail
                });
            }
        }
    });
}

/**
 * 手机快捷登录 - 第二步-获取手机号码
 */
export function wxappgetphone(params, success, fail = null) {
    uni.request({
        url: domain + '/index.php?s=/shared/user.login/wxapp_getphone',
        method: 'POST',
        data: {
            ...params,
            _acid: acid
        },
        success: success,
        fail: fail
    });
}

/**
 * 手机快捷登录 - 第三步-手机登录
 */
export function mobileLogin(params, success, fail = null) {
    uni.request({
        url: domain + '/index.php?s=/shared/user.login/mobileLogin',
        method: 'POST',
        data: {
            ...params,
            parent_id: '-1',
            _acid: acid
        },
        success: success,
        fail: fail
    });
}

/**
 * 终端设备类型审核
 */
export function auditJudge(success, fail = null) {
    uni.request({
        url: domain + '/index.php?s=/shared/user.home/auditJudge',
        data: {
            _acid: acid,
            version_number: version_number
        },
        success: success,
        fail: fail
    });
}

/**
 * 城市列表
 */
export function area_list(success, fail = null) {
    uni.request({
        url: domain + '/index.php?s=/shared/user.home/area_list',
        data: {
            _acid: acid
        },
        success: success,
        fail: fail
    });
}

/**
 *店铺属性分类
 */
export function categoryList(success, fail = null) {
    uni.request({
        url: domain + '/index.php?s=/shared/user.store/categoryList',
        data: {
            _acid: acid
        },
        success: success,
        fail: fail
    });
}

/**
 *用户注册接口
 */
export function userstorelist(success, fail = null) {
    uni.request({
        url: domain + '/index.php?s=/shared/user.store/list',
        success: success,
        fail: fail
    });
}

/**
 *首页信息
 */
export function homePage(success, fail = null) {
    uni.request({
        url: domain + '/index.php?s=/shared/user.home/homePage',
        method: 'POST',
        data: {
            _acid: acid
        },
        success: success,
        fail: fail
    });
}

/**
 *店铺详情-点击预定
 */
export function userstoreinfo(params, success, fail = null) {
    uni.request({
        url: domain + '/index.php?s=/shared/user.store/info',
        method: 'POST',
        data: {
            ...params,
            access_token: app.globalData.access_token,
            user_id: app.globalData.user_id,
            _acid: acid
        },
        success: success,
        fail: fail
    });
}

/**
 *房间列表
 */
export function houseList(params, success, fail = null) {
    uni.request({
        url: domain + 'index?s=/shared/user.store/houseList',
        method: 'POST',
        data: {
            ...params,
            access_token: app.globalData.access_token,
            _acid: acid
        },
        success: success,
        fail: fail
    });
}

/**
 *房间详细-点击提前预定
 */
export function houseInfo(params, success, fail = null) {
    uni.request({
        url: domain + '/index.php?s=/shared/user.store/houseInfo',
        method: 'POST',
        data: {
            ...params,
            access_token: app.globalData.access_token,
            _acid: acid
        },
        success: success,
        fail: fail
    });
}

/**
 *会员卡列表(会员卡类型)
 */
export function usercardlist(success, fail = null) {
    uni.request({
        url: domain + '/index.php?s=/shared/user.card/list',
        method: 'POST',
        data: {
            access_token: app.globalData.access_token,
            _acid: acid
        },
        success: success,
        fail: fail
    });
}

/**
 *我的会员卡
 */
export function mycard(success, fail = null) {
    uni.request({
        url: domain + '/index.php?s=/shared/user.card/mycard',
        method: 'POST',
        data: {
            access_token: app.globalData.access_token,
            _acid: acid
        },
        success: success,
        fail: fail
    });
}

/**
 *提交预约订单-预览
 */
export function submitpreview(params, success, fail = null) {
    uni.request({
        url: domain + '/index.php?s=/shared/user.house_order/submit_preview',
        method: 'POST',
        data: {
            ...params,
            access_token: app.globalData.access_token,
            _acid: acid
        },
        success: success,
        fail: fail
    });
}

/**
 *关闭支付取消订单
 */
export function houseordercancelOrder(params, success, fail = null) {
    uni.request({
        url: domain + '/index.php?s=/shared/user.house_order/cancelOrder',
        method: 'POST',
        data: {
            ...params,
            access_token: app.globalData.access_token,
            _acid: acid
        },
        success: success,
        fail: fail
    });
}

/**
 *支付 - 提交订单
 */
export function houseordersubmit(params, success, fail = null) {
    uni.request({
        url: domain + '/index.php?s=/shared/user.house_order/submit',
        method: 'POST',
        data: {
            ...params,
            access_token: app.globalData.access_token,
            _acid: acid
        },
        success: success,
        fail: fail
    });
}

/**
 *点击支付
 */
export function houseorderorderPay(params, success, fail = null) {
    uni.request({
        url: domain + '/index.php?s=/shared/user.house_order/orderPay',
        method: 'POST',
        data: {
            ...params,
            access_token: app.globalData.access_token,
            _acid: acid
        },
        success: success,
        fail: fail
    });
}

/**
 *店铺商品列表-点击客服
 */
export function goodscatList(params, success, fail = null) {
    uni.request({
        url: domain + '/index.php?s=/repast/user.goods/catList',
        method: 'POST',
        data: {
            ...params,
            access_token: app.globalData.access_token,
            _acid: acid
        },
        success: success,
        fail: fail
    });
}

/**
 *店铺商家码
 */
export function storeqrcode(params, success, fail = null) {
    uni.request({
        url: domain + '/index.php?s=/shared/user.store/qrcode',
        method: 'POST',
        data: {
            ...params,
            access_token: app.globalData.access_token,
            _acid: acid
        },
        success: success,
        fail: fail
    });
}

/**
 *用户管理信息(我的用户信息)
 */
export function userindex(success, fail = null) {
    uni.request({
        url: domain + '/index.php?s=/shared/user.user/index',
        method: 'POST',
        data: {
            access_token: app.globalData.access_token,
            _acid: acid
        },
        success: success,
        fail: fail
    });
}
/**
 * 提前使用订单
 */
export function settinguser(params,success, fail = null) {
    uni.request({
        url: domain + '/index?s=/shared/user.user/setting',
        method: 'POST',
        data: {
            ...params,
            access_token: app.globalData.access_token,
            _acid: acid
        },
        success: success,
        fail: fail
    });
}
/**
 * 提前使用订单
 */
export function startOrdersEarly(params,success, fail = null) {
    uni.request({
        url: domain + '/index.php?s=/shared/user.house_order/useOrdersEarly',
        method: 'POST',
        data: {
            ...params,
            access_token: app.globalData.access_token,
            _acid: acid
        },
        success: success,
        fail: fail
    });
}
/**
 * 提前结束订单
 */
export function endOrdersEarly(params,success, fail = null) {
    uni.request({
        url: domain + '/index.php?s=/shared/user.house_order/endOrdersEarly',
        method: 'POST',
        data: {
            ...params,
            access_token: app.globalData.access_token,
            _acid: acid
        },
        success: success,
        fail: fail
    });
}

/**
 * 提前结束订单
 */
export function timePreview(params,success, fail = null) {
    uni.request({
        url: domain + '/index?s=/shared/user.store/timePreview',
        method: 'POST',
        data: {
            ...params,
            _acid: acid
        },
        success: success,
        fail: fail
    });
}

/**
 *优惠券列表
 */
export function couponList(success, fail = null) {
    uni.request({
        url: domain + '/index.php?s=/shared/user.user/couponList',
        method: 'POST',
        data: {
            access_token: app.globalData.access_token,
            _acid: acid
        },
        success: success,
        fail: fail
    });
}

/**
 * 头像图片等附件上传
 */
export function uploadImg(params,success, fail = null) {
    uni.uploadFile({
        url: domain + '/index?s=/shared/user.user/uploadImg',
        filePath: params,
        name: 'file',
        method: 'POST',
        formData: {
            access_token: app.globalData.access_token,
            _acid: acid
        },
        success: success
    });
}
/**
 *美团抖音优惠券
 */
export function cardCouponList(success, fail = null) {
    uni.request({
        url: domain + '/index.php?s=/shared/user.user/cardCouponList',
        method: 'POST',
        data: {
            access_token: app.globalData.access_token,
            _acid: acid
        },
        success: success,
        fail: fail
    });
}

/**
 *优惠购券
 */
export function rechargeindex(params, success, fail = null) {
    uni.request({
        url: domain + '/index.php?s=/shared/user.recharge/index',
        method: 'POST',
        data: {
            ...params,
            access_token: app.globalData.access_token,
            _acid: acid
        },
        success: success,
        fail: fail
    });
}

/**
 *已使用列表
 */
export function cardCouponOrder(params, success, fail = null) {
    uni.request({
        url: domain + '/index.php?s=/shared/user.user/cardCouponOrder',
        method: 'POST',
        data: {
            ...params,
            access_token: app.globalData.access_token,
            _acid: acid
        },
        success: success,
        fail: fail
    });
}

/**
 *美团点评验券
 */
export function verificationCardCoupon(params, success, fail = null) {
    uni.request({
        url: domain + '/index.php?s=/shared/user.user/verificationCardCoupon',
        method: 'POST',
        data: {
            ...params,
            access_token: app.globalData.access_token,
            _acid: acid
        },
        success: success,
        fail: fail
    });
}

/**
 *店铺优惠券
 */
export function couponCenter(params, success, fail = null) {
    uni.request({
        url: domain + '/index.php?s=/shared/user.store/couponCenter',
        method: 'POST',
        data: {
            ...params,
            access_token: app.globalData.access_token,
            _acid: acid
        },
        success: success,
        fail: fail
    });
}

/**
 *抖音验券
 */
export function verifyTicket(params, success, fail = null) {
    uni.request({
        url: domain + '/index.php?s=/shared/user.douyin/verifyTicket',
        method: 'POST',
        data: {
            ...params,
            access_token: app.globalData.access_token,
            _acid: acid
        },
        success: success,
        fail: fail
    });
}
/**
 * 提交续单预览
 */
export function orderContinuePreview(params, success, fail = null) {
    uni.request({
        url: domain + '/index.php?s=/shared/user.house_order/orderContinuePreview',
        method: 'POST',
        data: {
            ...params,
            access_token: app.globalData.access_token,
            _acid: acid
        },
        success: success,
        fail: fail
    });
}
/**
 * 我要开店
 */
export function openStore(success, fail = null) {
    uni.request({
        url: domain + '/index.php?s=/shared/user.store/openStore',
        method: 'POST',
        data: {
            access_token: app.globalData.access_token,
            _acid: acid
        },
        success: success,
        fail: fail
    });
}

/**
 * 提交预约订单
 */
export function orderContinuePay(params, success, fail = null) {
    uni.request({
        url: domain + '/index.php?s=/shared/user.house_order/orderContinuePay',
        method: 'POST',
        data: {
            ...params,
            access_token: app.globalData.access_token,
            _acid: acid
        },
        success: success,
        fail: fail
    });
}
/**
 *订单列表
 */
export function houseorderlist(params, success, fail = null) {
    uni.request({
        url: domain + '/index.php?s=/shared/user.house_order/list',
        method: 'POST',
        data: {
            ...params,
            access_token: app.globalData.access_token,
            _acid: acid
        },
        success: success,
        fail: fail
    });
}

/**
 *订单详细(订单详情-点击支付)
 */
export function houseorderdetails(params, success, fail = null) {
    uni.request({
        url: domain + '/index.php?s=/shared/user.house_order/details',
        method: 'POST',
        data: {
            ...params,
            access_token: app.globalData.access_token,
            _acid: acid
        },
        success: success,
        fail: fail
    });
}

/**
 *消息通知统计
 */
export function messagepage(success, fail = null) {
    uni.request({
        url: domain + '/index.php?/shared/user.message/page',
        success: success,
        fail: fail
    });
}

/**
 *消息通知
 */
export function messagelist(success, fail = null) {
    uni.request({
        url: domain + '/index.php?s=/shared/user.message/list',
        success: success,
        fail: fail
    });
}

/**
 *是否切换到商户
 */
export function toggleStore(success, fail = null) {
    uni.request({
        url: domain + 'index?S=/shared/user.user/toggleStore',
        success: success,
        fail: fail
    });
}

/**
 *合伙人列表
 */
export function userpartner(success, fail = null) {
    uni.request({
        url: domain + '/index.php?s=/shared/user.partner/index',
        success: success,
        fail: fail
    });
}

/**
 * 储值卡
 */
export function storeuserMoney(success, fail = null) {
    uni.request({
        url: domain + '/index?s=/shared/user.store/userMoney',
        method: 'POST',
        data: {
            _acid: acid,
            access_token: app.globalData.access_token
        },
        success: success,
        fail: fail
    });
}

/**
 * 储值卡列表新
 */
export function userrechargCard(success, fail = null) {
    uni.request({
        url: domain + '/index.php?s=/shared/user.user/rechargCard',
        method: 'POST',
        data: {
            _acid: acid,
            access_token: app.globalData.access_token
        },
        success: success,
        fail: fail
    });
}

/**
 * 充值活动列表新
 */
export function rechargeindexnew(success, fail = null) {
    uni.request({
        url: domain + '/index.php?s=/shared/user.recharge/index',
        method: 'POST',
        data: {
            _acid: acid,
            access_token: app.globalData.access_token
        },
        success: success,
        fail: fail
    });
}

/**
 * 充值新
 */
export function userrechargenew(params,success, fail = null) {
    uni.request({
        url: domain + '/index.php?s=/shared/user.user/recharge',
        method: 'POST',
        data: {
            ...params,
            _acid: acid,
            access_token: app.globalData.access_token
        },
        success: success,
        fail: fail
    });
}

/**
 * 我要开店
 */
export function userstoreopenStore(params,success, fail = null) {
    uni.request({
        url: domain + '/index?s=/shared/user.store//openStore',
        method: 'POST',
        data: {
            ...params,
            _acid: acid,
            access_token: app.globalData.access_token
        },
        success: success,
        fail: fail
    });
}


/**
 *充值-点击显示
 */
export function rechargeList(params, success, fail = null) {
    uni.request({
        url: domain + '/index.php?s=/shared/user.store/rechargeList',
        method: 'POST',
        data: {
            ...params,
            _acid: acid,
            access_token: app.globalData.access_token
        },
        success: success,
        fail: fail
    });
}

/**
 *店铺列表
 */
export function storelist(params,success, fail = null) {
    uni.request({
        url: domain + '/index.php?s=/shared/user.store/list',
        method: 'POST',
        data: {
            ...params,
            _acid: acid
        },
        success: success,
        fail: fail
    });
}

/**
 *点击充值事件
 */
export function storerecharge(success, fail = null) {
    uni.request({
        url: domain + '/index.php?s=/shared/user.store/recharge',
        data: {
            _acid: acid
        },
        success: success,
        fail: fail
    });
}

/**
 *店铺充值明细
 */
export function moneyBill(success, fail = null) {
    uni.request({
        url: domain + '/index.php?s=/shared/user.store/moneyBill',
        data: {
            _acid: acid
        },
        success: success,
        fail: fail
    });
}

/**
 *点击押金充值-显示
 */
export function usercashgrade(success, fail = null) {
    uni.request({
        url: domain + '/index.php?s=/plugin/usercashgrade.user.usercashgrade/index',
        data: {
            _acid: acid
        },
        success: success,
        fail: fail
    });
}

/**
 *押金充值点击事件
 */
export function usercashgradeordersubmit(success, fail = null) {
    uni.request({
        url: domain + '/index.php?s=/plugin/usercashgrade.user.usercashgrade_order/submit',
        data: {
            _acid: acid
        },
        success: success,
        fail: fail
    });
}

/**
 *会员卡(我的会员卡)
 */
export function usercardmycard(success, fail = null) {
    uni.request({
        url: domain + '/index.php?s=/shared/user.card/mycard',
        data: {
            _acid: acid
        },
        success: success,
        fail: fail
    });
}

/**
 *茶艺师订单
 */
export function teaspecialistorder(success, fail = null) {
    uni.request({
        url: domain + '/index.php?s=/shared/user.tea_specialist_order/list',
        data: {
            _acid: acid
        },
        success: success,
        fail: fail
    });
}

/**
 *礼品卡
 */
export function giftcard(success, fail = null) {
    uni.request({
        url: domain + '/index.php?s=/shared/user.gift_card/index',
        data: {
            _acid: acid
        },
        success: success,
        fail: fail
    });
}

/**
 *礼品卡详情
 */
export function giftcarddetail(success, fail = null) {
    uni.request({
        url: domain + '/index.php?s=/shared/user.gift_card/detail',
        data: {
            _acid: acid
        },
        success: success,
        fail: fail
    });
}

/**
 *礼品卡-生成订单
 */
export function giftcardsubmitOrder(success, fail = null) {
    uni.request({
        url: domain + '/index.php?s=/shared/user.gift_card/submitOrder',
        data: {
            _acid: acid
        },
        success: success,
        fail: fail
    });
}

/**
 *礼品卡订单支付
 */
export function giftcardpayOrder(success, fail = null) {
    uni.request({
        url: domain + 'index?s=/shared/user.gift_card/payOrder',
        data: {
            _acid: acid
        },
        success: success,
        fail: fail
    });
}

/**
 *礼品卡订单
 */
export function giftcardorderList(success, fail = null) {
    uni.request({
        url: domain + '/index.php?s=/shared/user.gift_card/orderList',
        data: {
            _acid: acid
        },
        success: success,
        fail: fail
    });
}

/**
 *礼品卡发放记录
 */
export function releaseRecord(success, fail = null) {
    uni.request({
        url: domain + '/index.php?s=/shared/user.gift_card/releaseRecord',
        data: {
            _acid: acid
        },
        success: success,
        fail: fail
    });
}

/**
 *礼品卡-收到礼品卡记录
 */
export function drawRecord(success, fail = null) {
    uni.request({
        url: domain + '/index.php?s=/shared/user.gift_card/drawRecord',
        data: {
            _acid: acid
        },
        success: success,
        fail: fail
    });
}

/**
 *兑换中心
 */
export function conversionCode(success, fail = null) {
    uni.request({
        url: domain + '/index.php?s=/shared/user.user/conversionCode',
        data: {
            _acid: acid
        },
        success: success,
        fail: fail
    });
}

/**
 *茶艺师申请
 */
export function teaspecialistapply(success, fail = null) {
    uni.request({
        url: domain + '/index?s=/shared/user.tea_specialist/apply',
        data: {
            _acid: acid
        },
        success: success,
        fail: fail
    });
}

/**
 * 隐私/协议
 */
export function agreementDetails(params,success, fail = null) {
    uni.request({
        url: domain + '/index.php?s=/shared/user.home/agreementDetails',
        method: 'POST',
        data: {
            ...params,
            _acid: acid
        },
        success: success,
        fail: fail
    });
}
/**
 * 小程序订阅模板
 */
export function wxSubtopic(success, fail = null) {
    uni.request({
        url: domain + '/index.php?s=/shared/user.user/wxSubtopic',
        method: 'POST',
        data: {
            _acid: acid,
            access_token: app.globalData.access_token
        },
        success: success,
        fail: fail
    });
}
